

    google.load("visualization", "1", {packages: ["corechart"]});
    google.setOnLoadCallback(drawChartCpu);

    var cpu, ram;
    function drawChartCpu() {
        var data = google.visualization.arrayToDataTable([
            ['HORA', 'CPU', 'RAM'],
            [' ', 0, 0],
            [' ', 0, 0],
            [' ', 0, 0],
            [' ', 0, 0],
            [' ', 0, 0],
            [' ', 0, 0],
            [' ', 0, 0]
        ]);

        var options = {
            title: 'Estado de la RAM y el CPU % de uso',
            hAxis: {title: 'HORA', titleTextStyle: {color: '#333'}},
            vAxis: {minValue: 0,
                    maxValue: 100
                    
            },
            
            width: 500,
            height: 300,
            
            is3D: true
        };

        var chart = new google.visualization.AreaChart(document.getElementById('div_cpu_ram_areaChart'));
        chart.draw(data, options);
        
        setInterval(function() {
        
            $.ajax({
                type: 'POST',
                url: 'cpu_ram_chart.php',
                dataType: 'json',
                async: true,
                data:{
                    req:'cpu_ram'
                },
                
                success: function(data) {
                  // console.log("succes");
                  // console.log(data);
                   
                   //console.log(data);
                   if(data.success){
                     //   console.log(data);
                       // console.log("json success");                         
                            cpu = data.result.porcentajeCpu;
                            ram = data.result.porcentajeRam;    
                    }
                }
            });
            //console.log("SALE DEL AJAX");
            //console.log("cpu "+ cpu);
            //console.log("ram "+ ram);
            var d = new Date();
            data.removeRow(0);
            data.addRow([(d.toLocaleTimeString()).toString(), cpu, ram]);
            chart.draw(data, options);
        }, 1000);
    }

//hhh
